package com.qijian.flowable.controller;

import java.util.List;
import lombok.RequiredArgsConstructor;
import com.qijian.common.utils.mybatis.WhereEntityTool;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qijian.common.annotation.Log;
import com.qijian.common.core.controller.BaseController;
import com.qijian.common.core.domain.AjaxResult;
import com.qijian.common.enums.BusinessType;
import com.qijian.flowable.domain.FlowableRecordPower;
import com.qijian.flowable.domain.query.FlowableRecordPowerQuery;
import com.qijian.flowable.service.IFlowableRecordPowerService;
import com.qijian.common.utils.poi.ExcelUtil;
import com.qijian.common.core.page.TableDataInfo;

/**
 * 流程记录查看权限Controller
 *
 * @author qijian
 * @date 2021-09-17
 */
@Api(tags = "流程模块：流程记录查看权限")
@RestController
@RequiredArgsConstructor
@RequestMapping("/flowable/flowableRecordPower")
public class FlowableRecordPowerController extends BaseController {

    private final IFlowableRecordPowerService flowableRecordPowerService;

    /**
     * 查询流程记录查看权限列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:flowableRecordPower:list')")
    @GetMapping("/list")
        public TableDataInfo list(FlowableRecordPowerQuery query, IPage<FlowableRecordPower> page) {
        return getDataTable(flowableRecordPowerService.page(Page.of(page.getCurrent(), page.getSize()), WhereEntityTool.invoke(query)));
    }
    
    /**
     * 导出流程记录查看权限列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:flowableRecordPower:export')")
    @Log(title = "流程记录查看权限" , businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FlowableRecordPowerQuery query) {
        return new ExcelUtil<>(FlowableRecordPower. class).exportExcel(flowableRecordPowerService.list( WhereEntityTool.invoke(query)), "流程记录查看权限数据");
    }

    /**
     * 获取流程记录查看权限详细信息
     */
    @PreAuthorize("@ss.hasPermi('flowable:flowableRecordPower:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(flowableRecordPowerService.getById(id));
    }

    /**
     * 新增流程记录查看权限
     */
    @PreAuthorize("@ss.hasPermi('flowable:flowableRecordPower:add')")
    @Log(title = "流程记录查看权限" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowableRecordPower flowableRecordPower) {
        return toAjax(flowableRecordPowerService.save(flowableRecordPower));
    }

    /**
     * 修改流程记录查看权限
     */
    @PreAuthorize("@ss.hasPermi('flowable:flowableRecordPower:edit')")
    @Log(title = "流程记录查看权限" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowableRecordPower flowableRecordPower) {
        return toAjax(flowableRecordPowerService.updateById(flowableRecordPower));
    }

    /**
     * 删除流程记录查看权限
     */
    @PreAuthorize("@ss.hasPermi('flowable:flowableRecordPower:remove')")
    @Log(title = "流程记录查看权限" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids) {
        return toAjax(flowableRecordPowerService.removeByIds(ids));
    }
}
